<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script src="./react/react.development.js"></script>
  <script src="./react/react-dom.development.js"></script>
  <script src="./react/babel.min.js"></script>

  <div id="app"></div>

  <script type="text/babel">

    class App extends React.Component {
      constructor(props){
        super(props)
        this.state = {
          isLogin: false,
          isShow: true
        }
      }
      render() {
        let {isLogin, isShow} = this.state
        let login = (
          <div style={{display:isShow?"block":"none"}}>
            <p>亲，请先登录</p>
            <button onClick={e => {this.loginClick()}}>登录</button>
          </div>
        )
        let register = (
          <div>
            <p>欢迎回来</p>  
            <button onClick={e => {this.loginClick()}}>注销</button>
          </div>
        )
        console.log(register)
        return (
          /* 方案一：条件判断 */
          <div>
            {
              isLogin?register:login
            }
            <button onClick={()=>{this.displayClick()}}>设置display</button>
          </div>
        );
      }
      loginClick(){
        this.setState({
          isLogin: !this.state.isLogin
        })
      }
      displayClick(){
        this.setState({
          isShow: !this.state.isShow
        })
      }
    }
    ReactDOM.render(<App/>, document.getElementById('app'))
  </script>
</body>

</html>